//
//  CYHttpTool.h
//  CreditAddressBook
//
//  Created by Lee on 15/4/24.
//  Copyright (c) 2015年 Lee. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CYURL.h"
#import "AFHTTPRequestOperation.h"

typedef void (^HttpRequestSuccess)(id json);
typedef void (^HttpRequestSuccess1)(id data);
typedef void (^HttpRequestFailure)(NSError *error);
typedef void (^HttpRequestFailure1)(NSString *message, NSError *error);
typedef void (^HttpRequestFailure2)(NSString *message, BOOL isLogin);

@interface CYHttpTool : NSObject

/**
 *  发送一个get请求
 */
+ (void)getWithURL:(NSString *)url params:(NSDictionary *)params success:(HttpRequestSuccess)success failure:(HttpRequestFailure)failure;

/**
 *  发送一个10086get请求
 */
+ (void)get10086WithURL:(NSString *)url params:(NSDictionary *)params success:(HttpRequestSuccess)success failure:(HttpRequestFailure)failure;
/**
 *  发送一个189get请求
 */
+ (void)get189WithURL:(NSString *)url params:(NSDictionary *)params success:(HttpRequestSuccess)success failure:(HttpRequestFailure)failure;


/**
 *  发送一个10010get请求
 */
+ (void)get10010WithURL:(NSString *)url params:(NSDictionary *)params success:(HttpRequestSuccess)success failure:(HttpRequestFailure)failure;


/**
 *  发送一个Post请求
 */
+ (AFHTTPRequestOperation *)postWithURL:(NSString *)url params:(NSDictionary *)params success:(HttpRequestSuccess)success failure:(HttpRequestFailure)failure;
/**
 *  发送一个Post请求
 */
+ (AFHTTPRequestOperation *)postWithURL:(NSString *)url params:(NSDictionary *)params success:(HttpRequestSuccess)success failure:(HttpRequestFailure)failure uploadProgress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block;
/**
 *  发送一个getSerializer请求
 */
+ (void)getSerializerWithURL:(NSString *)url params:(NSDictionary *)params success:(HttpRequestSuccess)success failure:(HttpRequestFailure)failure;
/**
 *  发送一个Post Serializer请求
 */
+ (void)postSerializerWithURL:(NSString *)url params:(NSDictionary *)params success:(HttpRequestSuccess1)success failure:(HttpRequestFailure)failure;

/**
 *  文件上传
 */
+ (void)postWithURL:(NSString *)url params:(NSDictionary *)params image:(UIImage *)image success:(HttpRequestSuccess)success failure:(HttpRequestFailure)failure uploadProgress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block;

//云同步图片上传
+ (void)postCloudWithURL:(NSString *)url params:(NSDictionary *)params image:(UIImage *)image success:(HttpRequestSuccess)success failure:(HttpRequestFailure)failure uploadProgress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block;
@end
